Computers include general purpose central processing units (CPUs) that are designed to execute a specific set of system instructions. A group of processors that have similar architecture or design specifications may be considered to be members of the same processor family. Examples of current processor families include the Motorola 680X0 processor family, manufactured by Motorola, Inc. of Phoenix, Ariz.; the Intel 80X86 processor family, manufactured by Intel Corporation of Sunnyvale, Calif.; and the PowerPC processor family, which is manufactured by Motorola, Inc. and used in computers manufactured by Apple Computer, Inc. of Cupertino, Calif. Although a group of processors may be in the same family because of their similar architecture and design considerations, processors may vary widely within a family according to their clock speed and other performance parameters.
Each family of microprocessors executes instructions that are unique to the processor family. The collective set of instructions that a processor or family of processors can execute is known as the processor's instruction set. As an example, the instruction set used by the Intel 80X86 processor family is incompatible with the instruction set used by the PowerPC processor family. The Intel 80X86 instruction set is based on the Complex Instruction Set Computer (CISC) format. The Motorola PowerPC instruction set is based on the Reduced Instruction Set Computer (RISC) format. CISC processors use a large number of instructions, some of which can perform rather complicated functions, but which require generally many clock cycles to execute. RISC processors use a smaller number of available instructions to perform a simpler set of functions that are executed at a much higher rate.
The uniqueness of the processor family among computer systems also typically results in incompatibility among the other elements of hardware architecture of the computer systems. A computer system manufactured with a processor from the Intel 80X86 processor family will have a hardware architecture that is different from the hardware architecture of a computer system manufactured with a processor from the PowerPC processor family. Because of the uniqueness of the processor instruction set and a computer system's hardware architecture, application software programs are typically written to run on a particular computer system running a particular operating system.
A computer manufacturer will want to maximize its market share by having more rather than fewer applications run on the microprocessor family associated with the computer manufacturer's product line. To expand the number of operating systems and application programs that can run on a computer system, a field of technology has developed in which a given computer having one type of CPU, called a host, will include an emulator program that allows the host computer to emulate the instructions of an unrelated type of CPU, called a guest. Thus, the host computer will execute an application that will cause one or more host instructions to be called in response to a given guest instruction. Thus, the host computer can both run software designed for its own hardware architecture and software written for computers having an unrelated hardware architecture. As a more specific example, a computer system manufactured by Apple Computer, for example, may run operating systems and programs written for PC-based computer systems. It may also be possible to use an emulator program to operate concurrently on a single CPU multiple incompatible operating systems. In this arrangement, although each operating system is incompatible with the other, an emulator program can host one of the two operating systems, allowing the otherwise incompatible operating systems to run concurrently on the same computer system.
When a guest computer system is emulated on a host computer system, the guest computer system is said to be a virtual machine, as the host computer system exists only as a software representation of the operation of the hardware architecture of the guest computer system. The terms emulator and virtual machine are sometimes used interchangeably to denote the ability to mimic or emulate the hardware architecture of an entire computer system. As an example, the Virtual PC software created by Connectix Corporation of San Mateo, Calif. emulates an entire computer that includes an Intel 80X86 Pentium processor and various motherboard components and cards. The operation of these components is emulated in the virtual machine that is being run on the host machine. An emulator program executing on the operating system software and hardware architecture of the host computer, such as a computer system having a PowerPC processor, mimics the operation of the entire guest computer system. The emulator program acts as the interchange between the hardware architecture of the host machine and the instructions transmitted by the software running within the emulated environment.
Another difficulty of using a hypervisor in an emulated computing environment is managing the memory space of the emulated computer system together with the memory space of the hypervisor itself. To improve the operation of the emulated computer system, the hypervisor will typically seek to operate the page tables of the host computer system such that the page tables of the host computer system largely mirror the page tables of the guest operating system. One difficulty of this approach is that the hypervisor code and its associated data is not mapped in to the page tables of the guest operating system. This is necessarily the case, as the emulated computer system is not aware that a hypervisor is hosting the system on the hardware of the host computer system. As such, the page table of the hypervisor does not completely match the page table of the guest computer system. The page table of the hypervisor includes the mapping of the code and data of the hypervisor itself.
If it is desired to emulate the entire hardware architecture of the guest system, it is often useful or desirable to make maximum use of the hardware in the host computer system, including, for example, the memory management unit, the context switching hardware, the exception handling vectors, the interrupt routine pointers, and the floating point units of the host processor, and the memory of the host computer system. This hardware, however, is normally under the control of the host operating system and is shielded from access by user-level or application software. An exception is an event occurring in the computer system that cannot be resolved by the processor. An interrupt is a request sent to the processor to temporarily interrupt the current instruction stream to perform some other operation
One option to avoid this difficulty is to employ an emulation program that does not attempt to use the lower level hardware of the host computer system. This sort of approach is often used in the case of an emulation program that resides as an application program and runs on the host operating system. These application emulation programs, of course, are subject to the performance penalties of being an application program that runs on the host operating system of a host computer system. Further, these application emulation programs only gain access to the hardware features that are exposed to the application emulation program by the host operating system. As an example, an emulation program that runs as an application on the host operating system can include an exception handler. The difficulty is that the exception handler of the emulation program is separated from the processor of the host computer system by several software layers, creating a latency between the time that the host processor issues an exception and the time that the exception is identified to the exception handler of the emulation program. Another option is for the emulation program to share the hardware with the host operating system, assuming that support for the sharing of a computer system by an emulation program can be written into the hypervisor of the host operating system.
Another difficulty of using a hypervisor in an emulated computing environment is managing the memory space of the emulated computer system together with the memory space of the hypervisor itself. To improve the operation of the emulated computer system, the hypervisor will typically seek to operate the page tables of the host computer system such that the page tables of the host computer system largely mirror the page tables of the guest operating system. One difficulty of this approach is that the hypervisor code and its associated data is not mapped in to the page tables of the guest operating system. This is necessarily the case, as the emulated computer system is not aware that a hypervisor is hosting the system on the hardware of the host computer system. As such, the page table of the hypervisor does not completely match the page table of the host computer system. The page table of the hypervisor includes the mapping of the code and data of the hypervisor itself.
The mirroring by the hypervisor of the pages tables of the guest operating system raises the possibility that the address mapping of the guest operating system will conflict with the address mapping of the hypervisor, as the address mapping of the guest operating system may include the mapping of addresses over the mapped locations of the code and data of the hypervisor itself. One solution to this problem of conflicting page mappings is to alter the page table of the guest operating system when the mapping of the logical memory of the guest operating system conflicts with the mapping prescribed by the nearly identical page table of the hypervisor. Altering the page table of the emulated computer system is undesirable, however, in that it would introduce to the emulated computer system an unexpected change to its page tables, possibly introducing other incompatibilities or faults in the guest operating system.